<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<title>Travel Dream</title>
</h:head>
<link
rel="stylesheet"
href="customerHome.css"
type="text/css"
media="all"/>

<h:body onload="#tableBean.selectedTravel">
	<div id="templatemo_maincontainer">
<div id="templatemo_topsection">
  <div id="templatemo_title">TRAVEL Dream COMPANY</div>
  <div id="templatemo_slogan">The best way to travel !</div>
  <div id="hello"><h:outputText value="Hello #{userBean.getName()} !" /></div>
 
</div>
<div id="templatemo_left_column">
  <div id="templatemo_menu_top"></div>
  <div class="templatemo_menu"> 
  <ul>
   	 <li><a href="customerHome.xhtml">Home</a></li>
    <li><a href="myTravels.xhtml">My Travels</a></li>
    <li><a href="myInvitations.xhtml">My Invitations</a></li>
    <li><a href= "../logoutRedirect.xhtml">Logout</a></li>
  </ul></div>
  <div id="templatemo_contact">
    <strong>QUICK CONTACT<br /></strong>
Tel: 001-100-1000<br />
Fax: 002-200-2000<br />
Email: info[at]templatemo.com</div>
</div>
<div id="templatemo_right_column">
  <div class="innertube">
    <h1>My Travels</h1>

<div>

<h:form id="form">  
  
    <p:growl id="msgs" showDetail="true" />  
     
		       
  
    <p:dataTable id="travels" var="travel" value="#{myTravelsBean.getTravels(userBean.getUsername())}">  
  
  		 <p:column headerText="Place" style="width:11%">  
            <h:outputText value="#{travel.getMeanOfTransportation1().getTrip().toString()}" />  
        </p:column>  
        <p:column headerText="Dates" style="width:15%">  
            <h:outputText value="#{travel.getDateOfDepartureFormat()} - #{travel.getDateOfReturnFormat()}" />  
        </p:column>  
 
  
        <p:column headerText="Hotel" style="width:24%">  
            <strong><h:outputText value="#{travel.getHotelBean().getName()}" />  </strong>
            <br/>

            <h:outputText value="#{travel.getHotelBean().getClassification()} stars" />  
            <br/>
            <strong><h:outputText value="Adress :" /> </strong>
            <h:outputText value="#{travel.getHotelBean().getStreetNumber()} #{travel.getHotelBean().getStreetName()}" />  
            <br/>
        </p:column>  
  
        <p:column headerText="Excursions" style="width:30%">  
            <h:outputText value="#{travel.getExcursionsList()}" />  
        </p:column>  
        
         <p:column headerText="Transportation" style="width:21%">  
            <strong><h:outputText value="Go : " /></strong>          
            <br/>
            <h:outputText value="#{travel.getMeanOfTransportation1().getTransportationType().toString()}" />
            <br/>
            <h:outputText value="Departure time : #{travel.getMeanOfTransportation1().getDepartureTime()}" />
            <br/>
            <h:outputText value="Duration : #{travel.getMeanOfTransportation1().getDuration()} min" />
            <br/>
            <strong><h:outputText value="Return : " /></strong>          
            <br/>
            <h:outputText value="#{travel.getMeanOfTransportation2().getTransportationType().toString()}" />
            <br/>
            <h:outputText value="Departure time : #{travel.getMeanOfTransportation2().getDepartureTime()}" />
            <br/>
            <h:outputText value="Duration : #{travel.getMeanOfTransportation2().getDuration()} min" />
            <br/>
             </p:column>  
        
         <p:column headerText="Number of Participants" style="width:4%">  
            <h:outputText value="#{travel.getNomberOfPeople()}" />  
        </p:column>  
        
         <p:column headerText="Cost per person" style="width:4%">  
            <h:outputText value="#{travel.getPrice()} euros" />  
        </p:column>  
        
        
         <p:column headerText="Confirmed" style="width:4%">  
            <h:outputText value="#{travel.getConfirmation()}" />  
        </p:column>  
  
  
        <p:column style="width:5%"> 
        <p:commandButton value="Confirm" actionListener="#{myTravelsBean.confirmTravel(travel)}" process="@this" update=":form:travels" >
       			 <f:setPropertyActionListener value="#{travel}" target="#{myTravelsBean.selectedTravel}" />  
           		<p:confirm header="Confirmation" message="Confirm this travel?" icon="ui-icon-alert" />
           		<p:ajax listener="#{myTravelsBean.confirmTravel(travel)}" update=":form:msgs" />  
         </p:commandButton> 
         <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">  
        		<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>  
       			 <p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>       
   		 </p:confirmDialog>  
         
                <p:commandButton id="inviteButton" oncomplete="PF('invitationDialog').show()"  value="Invite a Friend"  title="View" process="@this">  
               		 <f:setPropertyActionListener value="#{travel}" target="#{myTravelsBean.selectedTravel}" />  
				 </p:commandButton>  
				 
				 <p:dialog header="Invitation" widgetVar="invitationDialog" resizable="false" id="invitationDlg"  
                showEffect="fade" hideEffect="fade" modal="true">  
  		
  
  		<p:outputPanel id="invitationDetail" style= "text-align:center;border:0;">  

            <h:panelGrid  columns="1" cellpadding="5" style= "text-align:center;border:0;">  

  		<h:outputText value="Insert the mail adress of your friend :" /> 

      	<p:inputText id="mail" name="mail" value="#{myTravelsBean.invited}"> 
      	 <p:ajax event="keyup"/>  
            </p:inputText> 
            <p:message for="mail" />
   
      	
      	
      	 <p:commandButton type="submit" value="Send"  oncomplete="PF('invitationDialog').hide()" process="@this">
      	 	 <p:ajax  listener="#{myTravelsBean.inviteFriend(userBean.getUsername(),myTravelsBean.invited,travel.getTravelID())}" update=":form:msgs" />           
      	 </p:commandButton>
      	 
		<h:outputText value="A mail will be send to your friend with a code."/>
		
		<h:outputText value ="With this code, he can vizualize the travel, and then join it !" />
  	</h:panelGrid>
  	</p:outputPanel>

    </p:dialog> 
    
    
      <p:commandButton id="deleteButton" value="Delete" actionListener="#{myTravelsBean.delete(travel)}" icon="ui-icon-trash"  process="@this" update=":form:msgs :form:travels">  
      		<p:confirm header="Delete" message="Delete this travel?" icon="ui-icon-alert" />         		
      </p:commandButton>   

				 
        </p:column>  

    </p:dataTable>  
  
    
    
     
             
    
    
    
   
</h:form>  
                      
   </div>
    
  </div>
</div>

</div>
<div id="templatemo_footer">TravelDream Company</div>



    </h:body>
</html>


